import Vue from 'vue'
import VueRouter from 'vue-router'

// 一级路由
import NotFound from '@/views/404'
import Layout from '@/views/common/layout'

// 跳转路由
import HomeIndex from '@/views/home/index'
import UserIndex from '@/views/user/index'
import CategoryIndex from '@/views/category/index'
import DishIndex from '@/views/dish/index'
import SetmealIndex from '@/views/setmeal/index'
import OrderIndex from '@/views/order/index'
import RecordIndex from '@/views/record/index'
import UserInfo from '@/views/user/userInfo/index'

// 编程路由
import addOrEditDish from '@/views/dish/addOrEdit/index'
import addOrEditSetmeal from '@/views/setmeal/addOrEdit/index'

import LoginIndex from '@/views/login/index'

Vue.use(VueRouter)

const routes = [
  { path: '/login', component: LoginIndex },
  {
    path: '/',
    component: Layout,
    redirect: '/login',
    children: [
      { path: '/home', component: HomeIndex },
      { path: '/user', component: UserIndex },
      { path: '/category', component: CategoryIndex },
      { path: '/dish', component: DishIndex },
      { path: '/setmeal', component: SetmealIndex },
      { path: '/order', component: OrderIndex },
      { path: '/record', component: RecordIndex },
      // 添加或修改菜品跳转路由
      { name: 'addOrEditDish', path: '/dish/addOrEdit', component: addOrEditDish },
      // 添加或修改套餐跳转路由
      { name: 'addOrEditSetmeal', path: '/setmeal/addOrEdit', component: addOrEditSetmeal },
      { name: 'UserInfo', path: '/userInfo', component: UserInfo }
    ]
  },
  { path: '*', component: NotFound }
]

const router = new VueRouter({
  routes
})

export default router
